<?php namespace Home\Model;
use Hdphp\Model\Model;
//User管理模型
class User extends Model{
	//指定表名,固定写法
    protected $table = "user";

	protected $validate = array(
		array('username','required','用户名不能为空',3,3),
		array('username','user:5,20','用户名长度5~20',3,3),
		array('usertel','phone','请填写正确手机号码',3,3),
	);
	
	//添加方法
	public function store(){
		if(Q('post.J_register_checkcode_phone') != strtolower(Code::get())) {
			View::error('验证码不正确',U('index'));
		}else{
			if($this->create()){
				
					//组合要添加的数组
					$data = array(
					'username' => Q('post.username'),
					'userpassword' => md5(Q('post.J_register_pasword_phone')),
					'usertel' => Q('post.usertel'),
						);
					//执行添加
					
					$this->add($data);
					return true;
			}
			return false;
		}
	}
//	
//	
	
}







